home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / math.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  10.3 KB  |  343 lines

  1.  
  2. /*  math.h
  3.  
  4.     Definitions for the math floating point package.
  5.  
  6. */
  7.  
  8. /*
  9.  *      C/C++ Run Time Library - Version 9.0
  10.  *
  11.  *      Copyright (c) 1987, 1998 by Borland International
  12.  *      All Rights Reserved.
  13.  *
  14.  */
  15. /* $Revision:   9.5  $ */
  16.  
  17. #ifndef  __MATH_H
  18. #define  __MATH_H
  19.  
  20. #if !defined(___STDDEF_H)
  21. #include <_stddef.h>
  22. #endif
  23.  
  24. #if !defined(RC_INVOKED)
  25.  
  26. #if defined(__STDC__)
  27. #pragma warn -nak
  28. #endif
  29.  
  30. #pragma pack(push, 1)
  31.  
  32. #endif  /* !RC_INVOKED */
  33.  
  34.  
  35. #if !defined(__STDC__) /* NON-ANSI */
  36.  
  37. #ifdef __cplusplus
  38.   extern "C" {
  39. #endif
  40.  
  41. /* Intrinsic functions listed before any namespace */
  42.  
  43. double      _RTLENTRY __sin__ (double __x);
  44. double      _RTLENTRY __cos__ (double __x);
  45. long double _RTLENTRY __cosl__(long double __x);
  46. long double _RTLENTRY __sinl__(long double __x);
  47. int         _RTLENTRY __abs__ (int);
  48.  
  49. #ifdef __cplusplus
  50. }  // extern "C"
  51. #endif
  52.  
  53.  
  54. #ifdef __cplusplus
  55.     /* use class complex instead of _cabs in C++ (now in STL 2.0) */
  56. #else
  57. struct complex      /* as used by "_cabs" function */
  58. {
  59.     double  x, y;
  60. };
  61.  
  62. struct _complexl    /* as used by "_cabsl" function */
  63. {
  64.     long double  x, y;
  65. };
  66.  
  67. #define cabs(z)     (hypot  ((z).x, (z).y))
  68. #define cabsl(z)    (hypotl ((z).x, (z).y))
  69. #endif /* __cplusplus */
  70. #endif /* NON-ANSI */
  71.  
  72. #ifdef __cplusplus
  73.   namespace std {
  74.   // Rename these to something that won't conflict with STL 2.0
  75.   #define exception math_exception
  76.   #define _exceptionl math_exceptionl
  77. #endif
  78.  
  79. typedef enum
  80. {
  81.     DOMAIN = 1,    /* argument domain error -- log (-1)        */
  82.     SING,          /* argument singularity  -- pow (0,-2))     */
  83.     OVERFLOW,      /* overflow range error  -- exp (1000)      */
  84.     UNDERFLOW,     /* underflow range error -- exp (-1000)     */
  85.     TLOSS,         /* total loss of significance -- sin(10e70) */
  86.     PLOSS,         /* partial loss of signif. -- not used      */
  87.     STACKFAULT     /* floating point unit stack overflow       */
  88. }   _mexcep;
  89.  
  90. /* Constants rounded for 21 decimals. */
  91. #define M_E         2.71828182845904523536
  92. #define M_LOG2E     1.44269504088896340736
  93. #define M_LOG10E    0.434294481903251827651
  94. #define M_LN2       0.693147180559945309417
  95. #define M_LN10      2.30258509299404568402
  96. #define M_PI        3.14159265358979323846
  97. #define M_PI_2      1.57079632679489661923
  98. #define M_PI_4      0.785398163397448309616
  99. #define M_1_PI      0.318309886183790671538
  100. #define M_2_PI      0.636619772367581343076
  101. #define M_1_SQRTPI  0.564189583547756286948
  102. #define M_2_SQRTPI  1.12837916709551257390
  103. #define M_SQRT2     1.41421356237309504880
  104. #define M_SQRT_2    0.707106781186547524401
  105.  
  106. #define EDOM    33      /* Math argument */
  107. #define ERANGE  34      /* Result too large */
  108.  
  109. struct  exception
  110. {
  111.     int type;
  112.     char   _FAR *name;
  113.     double  arg1, arg2, retval;
  114. };
  115.  
  116. struct  _exceptionl
  117. {
  118.     int type;
  119.     char   _FAR *name;
  120.     long double  arg1, arg2, retval;
  121. };
  122.  
  123.  
  124. #define HUGE_VAL    _huge_dble
  125. extern double _RTLENTRY _EXPDATA _huge_dble;
  126. #define _LHUGE_VAL   _huge_ldble
  127. extern long double _RTLENTRY _EXPDATA _huge_ldble;
  128.  
  129. #ifdef __cplusplus
  130. extern "C" {
  131. #endif
  132. double      _RTLENTRY _EXPFUNC acos    (double __x);
  133. double      _RTLENTRY _EXPFUNC asin    (double __x);
  134. double      _RTLENTRY _EXPFUNC atan    (double __x);
  135. double      _RTLENTRY _EXPFUNC atan2   (double __y, double __x);
  136. double      _RTLENTRY _EXPFUNC ceil    (double __x);
  137. double      _RTLENTRY _EXPFUNC cos     (double __x);
  138. double      _RTLENTRY _EXPFUNC cosh    (double __x);
  139. double      _RTLENTRY _EXPFUNC exp     (double __x);
  140. double      _RTLENTRY _EXPFUNC fabs    (double __x);
  141. double      _RTLENTRY _EXPFUNC floor   (double __x);
  142. double      _RTLENTRY _EXPFUNC fmod    (double __x, double __y);
  143. double      _RTLENTRY _EXPFUNC frexp   (double __x, int * __exponent);
  144. double      _RTLENTRY _EXPFUNC ldexp   (double __x, int __exponent);
  145. double      _RTLENTRY _EXPFUNC log     (double __x);
  146. double      _RTLENTRY _EXPFUNC log10   (double __x);
  147. double      _RTLENTRY _EXPFUNC modf    (double __x, double * __ipart);
  148. double      _RTLENTRY _EXPFUNC pow     (double __x, double __y);
  149. double      _RTLENTRY _EXPFUNC sin     (double __x);
  150. double      _RTLENTRY _EXPFUNC sinh    (double __x);
  151. double      _RTLENTRY _EXPFUNC sqrt    (double __x);
  152. double      _RTLENTRY _EXPFUNC tan     (double __x);
  153. double      _RTLENTRY _EXPFUNC tanh    (double __x);
  154.  
  155. long double _RTLENTRY _EXPFUNC acosl  (long double __x);
  156. long double _RTLENTRY _EXPFUNC asinl  (long double __x);
  157. long double _RTLENTRY _EXPFUNC atan2l (long double __x, long double __y);
  158. long double _RTLENTRY _EXPFUNC atanl  (long double __x);
  159. long double _RTLENTRY _EXPFUNC ceill  (long double __x);
  160. long double _RTLENTRY _EXPFUNC coshl  (long double __x);
  161. long double _RTLENTRY _EXPFUNC cosl   (long double __x);
  162. long double _RTLENTRY _EXPFUNC expl   (long double __x);
  163. long double _RTLENTRY _EXPFUNC fabsl  (long double __x);
  164. long double _RTLENTRY _EXPFUNC floorl (long double __x);
  165. long double _RTLENTRY _EXPFUNC fmodl  (long double __x, long double __y);
  166. long double _RTLENTRY _EXPFUNC frexpl (long double __x, int * __exponent);
  167. long double _RTLENTRY _EXPFUNC ldexpl (long double __x, int __exponent);
  168. long double _RTLENTRY _EXPFUNC log10l (long double __x);
  169. long double _RTLENTRY _EXPFUNC logl   (long double __x);
  170. long double _RTLENTRY _EXPFUNC modfl  (long double __x, long double * __ipart);
  171. long double _RTLENTRY _EXPFUNC powl   (long double __x, long double __y);
  172. long double _RTLENTRY _EXPFUNC sinhl  (long double __x);
  173. long double _RTLENTRY _EXPFUNC sinl   (long double __x);
  174. long double _RTLENTRY _EXPFUNC sqrtl  (long double __x);
  175. long double _RTLENTRY _EXPFUNC tanhl  (long double __x);
  176. long double _RTLENTRY _EXPFUNC tanl   (long double __x);
  177.  
  178.  
  179. double      _RTLENTRY _EXPFUNC atof    (const char * __s);
  180.  
  181. #if !defined(__STDC__) /* NON_ANSI */
  182.  
  183. #if !defined(__ABS_DEFINED)
  184. #define __ABS_DEFINED
  185. #ifdef __cplusplus
  186. inline int _RTLENTRY  abs(int __x) { return __abs__(__x); }
  187. #else
  188. int         _RTLENTRYF _EXPFUNC abs(int __x);
  189. #  define abs(x)   __abs__(x)
  190. #endif
  191. #endif /* __ABS_DEFINED */
  192.  
  193. long        _RTLENTRY _EXPFUNC labs    (long __x);
  194. double      _RTLENTRY _EXPFUNC pow10   (int __p);
  195.  
  196. long double _RTLENTRY _EXPFUNC _atold  (const char * __s);
  197.  
  198. int         _RTLENTRY          _matherr(struct exception  *__e);
  199. int         _RTLENTRY          _matherrl(struct _exceptionl *__e);
  200.  
  201. double      _RTLENTRY _EXPFUNC hypot   (double __x, double __y);
  202. double      _RTLENTRY _EXPFUNC poly    (double __x, int __degree, double __coeffs []);
  203. long double _RTLENTRY _EXPFUNC hypotl  (long double __x, long double __y);
  204. long double _RTLENTRY _EXPFUNC polyl   (long double __x, int __degree, long double __coeffs []);
  205. long double _RTLENTRY _EXPFUNC pow10l  (int __p);
  206.  
  207. #if defined (_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS >= 64)
  208. __int64     _RTLENTRY _EXPFUNC   _atoi64(const char * __s);
  209. char *      _RTLENTRY   _EXPFUNC _i64toa(__int64 __value, char *__strP, int __radix);
  210. char *      _RTLENTRY   _EXPFUNC _ui64toa(unsigned __int64 __value, char *__strP, int __radix);
  211. __int64     _RTLENTRY _EXPFUNC   _wtoi64(const wchar_t * __s);
  212. wchar_t *   _RTLENTRY   _EXPFUNC _i64tow(__int64 __value, wchar_t *__strP, int __radix);
  213. wchar_t *   _RTLENTRY   _EXPFUNC _ui64tow(unsigned __int64 __value, wchar_t *__strP, int __radix);
  214. #endif
  215. double      _RTLENTRY _EXPFUNC   _wtof(const wchar_t * __s);
  216. int         _RTLENTRY _EXPFUNC   _wtoi(const wchar_t * __s);
  217. long        _RTLENTRY _EXPFUNC   _wtol(const wchar_t * __s);
  218. long double _RTLENTRY _EXPFUNC   _wtold(const wchar_t * __s);
  219.  
  220. #endif  /* !__STDC__ */
  221.  
  222. #ifdef __cplusplus
  223. } // extern "C"
  224. } // std
  225. #undef exception
  226. #undef _exceptionl
  227. #endif /* __cplusplus */
  228.  
  229.  
  230. #if !defined(RC_INVOKED)
  231.  
  232. /* restore default packing */
  233. #pragma pack(pop)
  234.  
  235. #if defined(__STDC__)
  236. #pragma warn .nak
  237. #endif
  238.  
  239. #endif  /* !RC_INVOKED */
  240. #endif  /* __MATH_H */
  241.  
  242. #if defined(__cplusplus) && !defined(__USING_CNAME__) && !defined(__MATH_H_USING_LIST)
  243. #define __MATH_H_USING_LIST
  244.     using std::math_exception;
  245.     using std::math_exceptionl;
  246.     using std::_mexcep;
  247.     using std::_huge_dble;
  248.     using std::_huge_ldble;
  249.     using std::acos;
  250.     using std::asin;
  251.     using std::atan;
  252.     using std::atan2;
  253.     using std::ceil;
  254.     using std::cosh;
  255.     using std::exp;
  256.     using std::fabs;
  257.     using std::floor;
  258.     using std::fmod;
  259.     using std::frexp;
  260.     using std::ldexp;
  261.     using std::log;
  262.     using std::log10;
  263.     using std::modf;
  264.     using std::pow;
  265.     using std::sinh;
  266.     using std::sqrt;
  267.     using std::tan;
  268.     using std::tanh;
  269.     using std::acosl;
  270.     using std::asinl;
  271.     using std::atan2l;
  272.     using std::atanl;
  273.     using std::ceill;
  274.     using std::coshl;
  275.     using std::expl;
  276.     using std::fabsl;
  277.     using std::floorl;
  278.     using std::fmodl;
  279.     using std::frexpl;
  280.     using std::ldexpl;
  281.     using std::log10l;
  282.     using std::logl;
  283.     using std::modfl;
  284.     using std::powl;
  285.     using std::sinhl;
  286.     using std::sqrtl;
  287.     using std::tanhl;
  288.     using std::tanl;
  289.     using std::atof;
  290.  
  291. /*
  292.    Handle intrinsics specially.  If intrinsics are on, the compiler creates
  293.    a macro of the normal function mapping to the __ intrinsic version, ie:
  294.      #define strcpy __strcpy__
  295.    Thus, we can test the normal name as a macro to see if it's defined, and
  296.    only preform a using statement if it's not an intrinsic
  297. */
  298.  
  299. #   ifndef sin
  300.       using std::sin;
  301. #   endif // ifndef sin
  302. #   ifndef cos
  303.       using std::cos;
  304. #   endif // ifndef cos
  305. #   ifndef sinl
  306.       using std::sinl;
  307. #   endif // ifndef sinl
  308. #   ifndef cosl
  309.       using std::cosl;
  310. #   endif // ifndef cosl
  311.  
  312. # if !defined(__STDC__) /* NON_ANSI */
  313. #   ifndef abs
  314.       using std::abs;
  315. #   endif // ifndef abs
  316.  
  317.     using std::labs;
  318.     using std::pow10;
  319.     using std::_atold;
  320.     using std::_matherr;
  321.     using std::_matherrl;
  322.     using std::hypot;
  323.     using std::poly;
  324.     using std::hypotl;
  325.     using std::polyl;
  326.     using std::pow10l;
  327.  
  328. # if defined (_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS >= 64)
  329.     using std::_atoi64;
  330.     using std::_i64toa;
  331.     using std::_ui64toa;
  332.     using std::_wtoi64;
  333.     using std::_i64tow;
  334.     using std::_ui64tow;
  335.     using std::_wtof;
  336.     using std::_wtoi;
  337.     using std::_wtol;
  338.     using std::_wtold;
  339. # endif // _INTEGRAL_MAX_BITS
  340. # endif // !__STDC__
  341. #endif /* __USING_CNAME__ */
  342.  
  343.